package UseMap.LearnMap;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class FixedMap {
    public static void main(String[] args) {
        // 方式一: 最多添加10对不可变Map
        Map<String, String> fixed = Map.of("小平", "水", "小同", "ass");
        System.out.println(fixed);

        // 方式二: 随意添加操作entry对象
        HashMap<String,String> hm = new HashMap<>();
        hm.put("小平","水");
        hm.put("小同","大");
        hm.put("小美","美");
        Map<Object, Object> map = Map.ofEntries(hm.entrySet().toArray(new Map.Entry[0]));

        // JDK10方法
        Map<String, String> map1 = Map.copyOf(hm);

    }
}
